package com.chencong.online.function;

import com.chencong.online.bean.UserBehaviorBean;
import org.apache.flink.api.common.functions.AggregateFunction;

/**
 * @Author chencong
 * @Description 统计窗口內的次数(累加器)
 * @Date 7:36 下午 2021/12/19
 * @Param
 **/
public class ItemCountAggFunc implements AggregateFunction<UserBehaviorBean, Long, Long> {
    @Override
    public Long createAccumulator() {
        return 0L;
    }

    @Override
    public Long add(UserBehaviorBean value, Long accumulator) {
        return accumulator + 1;
    }

    @Override
    public Long getResult(Long accumulator) {
        return accumulator;
    }

    @Override
    public Long merge(Long a, Long b) {
        return a + b;
    }
}
